package com.example.mobile2021606128wje0413;

import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {


    private Button btnMainSuplieer;
    private Button btnMainBuy;
    private TextView tvMainEsult;
    private Button btnMainClose;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initView();
        btnMainClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog dialog;
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                builder.setTitle("普通对话框");
                builder.setIcon(R.mipmap.ic_launcher);
                builder.setMessage("是否确认退出应用：");
                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        MainActivity.this.finish();
                    }
                });
                builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();

                    }
                });
                dialog=builder.create();
                dialog.show();

            }
        });
    }

    private void initView() {
        btnMainSuplieer = (Button) findViewById(R.id.btn_main_suplieer);
        btnMainBuy = (Button) findViewById(R.id.btn_main_buy);
        tvMainEsult = (TextView) findViewById(R.id.tv_main_esult);
        btnMainClose = (Button) findViewById(R.id.btn_main_close);
    }

  //  public void gysx(View view) {
 //       AlertDialog dialog;
 //       AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
  //      builder.setIcon(R.mipmap.ic_launcher);
 //       builder.setSingleChoiceItems(new String[]{"新星汽车配件", "枫叶汽车配件", "细末汽车配件", "天辉汽车配件"}, btnMainSuplieer, new DialogInterface.OnClickListener() {
 //           @Override
  //          public void onClick(DialogInterface dialog, int which) {
  //              btnMainSuplieer=which


            }

 //       });
 //   }
//}